<!-- The ref attr used to find the swiper instance -->
<template>
	<div class="wrapper">
	  <swiper :options="swiperOption" v-if="showSwiper">
		<!-- slides -->
		<swiper-slide v-for="item of list" :key="item.id">
			<img class="swipe-img" :src="item.imgUrl" alt="去哪儿门票" style="opacity: 1;">
		</swiper-slide>
		
		<!-- Optional controls -->
		<div class="swiper-pagination"  slot="pagination"></div>
		
	  </swiper>
  </div>
</template>

<script>
	export default {
		name:'HomeSwiper',
		props: {
			list: Array
		},
		data() {
		  return {
				swiperOption: {
					pagination: '.swiper-pagination', //显示小圆点
					loop: true   //循环
				},
		  }
		},
		computed: {
			//实现加载页面时显示第一张轮播图，而不是最后一张，因为组件的显示是有初始化为空数组的list决定的
			showSwiper () {
				return this.list.length
			}
		},
	}
</script>

<style lang="stylus" scoped>
	.wrapper >>> .swiper-pagination-bullet-active
		background: #fff
	.wrapper
		overflow:hidden
		width:100%
		height: 0
		padding-bottom: 31.25%
		.swipe-img
			width: 100%
</style>